<?php
/**
 * Created by PhpStorm.
 * User: coffee
 * Date: 2018/1/9
 * Time: 上午10:10
 */

$app->group(['prefix' => '/a/events', 'middleware' => ['oauth.scopes:admin-basic', 'oauth.consumer:admin']], function () use ($app) {

    // 台历活动
    $app->post('/allowStudentCalendar', [
        'middleware' => ['oauth.scopes:admin-student-service'],
        'uses' => 'AdminEventsController@allowStudentCalendarPresent'
    ]);

    //TODO: allowStudentCalender -> studentCalendar
    $app->get('/allowStudentCalendar', [
        'uses' => 'AdminEventsController@retrieveStudentCalendarPresent'
    ]);

    $app->delete('/allowStudentCalendar', [
        'uses' => 'AdminEventsController@deleteStudentCalendarPresent'
    ]);

    $app->post('/studentCalendar', [
        'middleware' => ['oauth.scopes:admin-student-service admin-marketing'],
        'uses' => 'AdminEventsController@createStudentCalendarPresentEvent'
    ]);

    $app->put('/studentCalendar', [
        'uses' => 'AdminEventsController@updateStudentCalendarPresent'
    ]);

    $app->group(['prefix' => '/giftLesson'], function () use ($app) {
        $app->get('/manage', [
            'uses' => 'AdminGiftLessonShareController@retrieve'
        ]);

        $app->get('/students/{id}', [
            'uses' => 'AdminGiftLessonShareController@retrieveOne'
        ]);

        $app->put('/students/{id}', [
            'uses' => 'AdminGiftLessonShareController@update'
        ]);
    });


    // 拼读分享活动
    $app->group(['prefix' => '/phonics'], function () use ($app) {

        $app->get('/manage',[
            'uses' => 'AdminPhonicsStudentController@manage'
        ]);

        $app->get('/students/{id}',[
            'uses' => 'AdminPhonicsStudentController@retrieveOne'
        ]);

        $app->put('/students/{id}/privilege',[
            'uses' => 'AdminPhonicsStudentController@updatePrivilege'
        ]);

        $app->get('/students/{id}/share',[
            'uses' => 'AdminPhonicsShareController@retrieveStudentHistory'
        ]);

        $app->get('/withdraw',[
            'uses' => 'AdminPhonicsWithdrawController@manage'
        ]);

        // 确认微信提现转账
        $app->put('/withdraw/{id}/confirm',[
            'middleware' => ['oauth.scopes:admin-teacher-service-leader admin-finance'],
            'uses' => 'AdminPhonicsWithdrawController@confirm'
        ]);

        // 获取微信转账结果
        $app->get('/withdraw/{id}/transfer',[
            'uses' => 'AdminPhonicsWithdrawController@retrieveTransfer'
        ]);
    });
});